/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package rad.Java.MotelPlus.List;

import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import rad.Java.Common.Class.DefaultList;
import rad.Java.Common.Class.IList;
import rad.Java.MotelPlus.Class.Apt;

/**
 *
 * @author rogerio
 */
public class Tests extends DefaultList implements IList{

    public Tests()
    {
        _gsql.setTable("room");
    }

    public Apt get(int index)
    {
        return (Apt)_items.get(index);
    }

    public boolean fillList() {
        _gsql.prepare();
        _gsql.setValue("", "*");

        return mountList();
    }

    private boolean mountList()
    {
        try {
            if (!_gsql.execute(Boolean.FALSE)) {
                return false;
            }
            _items.clear();
            while (_gsql.next()) {
                Apt a = new Apt();
                a.get(_gsql.getResultSet());
                _items.add(a);
            }
            return true;
        } catch (SQLException ex) {
            Logger.getLogger(Tests.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }


}
